package com.wft;

import java.util.ArrayDeque;

public class Solution765 {
    private final int timeout = 3000;
    private ArrayDeque<Integer> queue;

    public Solution765() {
        queue = new ArrayDeque<Integer>();
    }

    public int ping(int t) {
        queue.add(t);

        while (queue.peek() != null) {
            int peek = queue.peek();
            if (queue.peek() + 3000 < t) {
                queue.poll();
            } else {
                break;
            }
        }
        return queue.size();
    }

    public static void main(String[] args) {
        Solution765 s = new Solution765();
        System.out.println(s.ping(1000));
        System.out.println(s.ping(2000));
        System.out.println(s.ping(3000));
        System.out.println(s.ping(4100));

    }
}
